<?php


namespace app\common\model;


use think\Model;

class Award extends Model
{
    // 开启自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';
    // 定义时间戳字段名
    protected $updateTime = false;

    protected $append = ['level','type'];

    public function getLevelAttr($value, $data)
    {
        if ($data['level_id']) {
            $re = AwardLevel::where('id', $data['level_id'])->value('name');
            return $re;
        }
    }

    public function getTypeAttr($value, $data)
    {
        if ($data['type_id']) {
            $re = AwardType::where('id', $data['type_id'])->value('name');
            return $re;
        }
    }
}